package servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class serviceTime extends HttpServlet{
	
	@Override
	public void init(ServletConfig config) throws ServletException {
		super.init(config);
		String maxOnLine = config.getInitParameter("maxOnLine");
		System.out.println("maxOnLine" + maxOnLine);
	}
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		ServletConfig servletConfig = getServletConfig();
		String maxOnLine = servletConfig.getInitParameter("maxOnLine");
		System.out.println("maxOnLine" + maxOnLine);
		
		resp.setContentType("text/html");
		Date date = new Date();
		System.out.println(date);
	
		SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
		String nowTime = simpleDateFormat.format(date);
		//返回给浏览器
		PrintWriter printWriter = resp.getWriter();
		printWriter.println("<p>"+ nowTime +"<p>");
		printWriter.close();
	}
	
}
